﻿Imports System.Windows.Forms

Public Class LoadReportDialog

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub LoadReportDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'load the reports
        Dim sql As String
        Dim TheView As DataView

        With ReportsBox

            If CurrentUser.Level = 5 Then
                sql = "select Report_ID, Report_Name + ' (' + User_Name + ')' as Report_Name from RD_Reports where Scenario_ID = '" & ModelForm.ScenarioBox.SelectedValue.ToString & "'"
            Else
                sql = "select Report_ID, Report_Name + ' (' + User_Name + ')' as Report_Name from RD_Reports where Scenario_ID = '" & ModelForm.ScenarioBox.SelectedValue.ToString & "' and User_Name = '" & CurrentUser.Name & "'"
            End If

            TheView = LoadDataView(sql)

            .DataSource = TheView
            .ValueMember = "Report_ID"
            .DisplayMember = "Report_Name"

        End With
    End Sub
End Class
